package com.socio.model;

import java.io.Serializable;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
public class Event implements Serializable {

	private static final long serialVersionUID = 8615002915956906205L;

	public static enum EventType {
		Facebook {
			public void incrementScores(User userWithScoresToIncrement) {
				userWithScoresToIncrement.incrementFacebookQuickScore();
				userWithScoresToIncrement.incrementQuickScore();
			}
		},
		Twitter {
			public void incrementScores(User userWithScoresToIncrement) {
				userWithScoresToIncrement.incrementTwitterQuickScore();
				userWithScoresToIncrement.incrementQuickScore();
			}
		};
		
		/**
		 * Increments the appropriate quick scores
		 * 
		 * @param userWithScoresToIncrement user containing score to update
		 */
		public abstract void incrementScores(User userWithScoresToIncrement);
	};
	
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	
	@Persistent
	private Day day;
	
	@Persistent
	private EventType type;
	
	@Persistent
	private String change = "";

	public Event() {
	}
	
	public Key getKey() {
		return key;
	}

	public void setKey(Key key) {
		this.key = key;
	}

	public Day getDay() {
		return day;
	}

	public void setDay(Day day) {
		this.day = day;
	}

	public EventType getType() {
		return type;
	}

	public void setType(EventType type) {
		this.type = type;
	}

	public String getChange() {
		return change;
	}

	public void setChange(String change) {
		this.change = change;
	}
}
